package cn.bugio.task11.controller;

import cn.bugio.task11.po.Person;
import cn.bugio.task11.po.Product;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

/**
 * <h1></h1>
 *
 * @version 1.0
 * @author: Vincent Vic
 * @since: 2021/11/24
 */
@Controller
public class ProductController {

    @RequestMapping("/product")
    public String index(Model model) {
        return "product";
    }

    @RequestMapping("/getProduct")
    @ResponseBody
    public List<Product> index(Integer[] ids) {
        System.out.println("ids => " + ids.length);
        List<Product> list = new ArrayList<Product>();
        for (Integer id : ids) {
            Product product = new Product();
            product.setProId(String.valueOf(id));
            product.setProName("测试"+id);
            list.add(product);
        }
        return list;
    }
}
